<%= javascript_include_tag "fckeditor/fckeditor" %>

<div class='form action_link'>
  <% form_for @product,:html=>{:multipart=>true} do |f| %>
    <%= f.error_messages %>
    <p>
      <label for="product_category_id">类别</label>
      <select name="product[category_id]" id="product_category_id">
        <option value="">请选择...</option>
        <%=option_groups_from_collection_for_select(Category.parent_categories,
          :children,
          :title,
          :id,
          :title, @product.category_id)%>
      </select>

      <a href="/categories"  class="action_edit">管理类别</a>
    </p>
    <p>
      <label for="product_brand_id">品牌</label>
      <%=  select("product", "brand_id", Brand.find(:all,:order => 'sort_order desc').collect {|b| [ b.name, b.id ] },{:prompt =>"请选择"}) %>
      <a href="javascript:void(0);" onclick="jQuery('#create_brand').show();" class="action_add">添加新品牌</a> |
      <a href="/brands"  class="action_edit">管理品牌</a>
    </p>

    <div id="create_brand" class="toolbar" style="display:none;">
      <div class="title">添加新品牌</div>
      <b>品牌名称</b>
      <input name="brand[name]" id="brand_name"></input>
      <a href="javascript:void(0);" onclick="addBrand();" class="action_add">添加</a>
      <a href="javascript:void(0);" onclick="jQuery('#create_brand').hide();" class="action_back">取消</a>
    </div>

    <p>
      <label for="product_name">名称</label>
      <%= f.text_field :name %>
    </p>
    <p>
      <label for="product_purchase_url">采购网址</label>
      <%= f.text_field :purchase_url,:size=>40 %>
    </p>

    <p>
      <label for="product_image─url">上传图片1</label>
      <%= file_column_field  "product", "image_url" %>
    </p>

    <p>
      <label for="product_image─url2">上传图片2</label>
      <%= file_column_field "product", "image_url2" %>
    </p>

    <p>
      <label for="product_image─url3">上传图片3</label>
      <%= file_column_field "product","image_url3" %>
    </p>

    <p>
      <label for="product_unit">单位</label>
      <%= f.text_field :unit,:size=>5 %>
    </p>

    <p>
      <label for="product_size">大小</label>
      <%= f.text_field :size,:size=>5 %>
    </p>



    <p>
      <label for="product_cost_price">成本价</label>
      <%= f.text_field :cost_price,:size=>5 %>
    </p>

    <p>
      <label for="product_cost_price">市场价</label>
      <%= f.text_field :official_price,:size=>5 %>
    </p>

    <p>
      <label for="product_retail_price">零售价</label>
      <%= f.text_field :retail_price,:size=>5 %>
    </p>

    <p>
      <label for="product_live_date">存活期</label>
      <%= f.text_field :live_date,:size=>1 %>天
    </p>

    <% if @product.id %>

      <p>
        <label for="product_active">激活</label>
        <%= f.check_box :active %>
      </p>

    <%end%>

    <p>
      <label for="product_active">推荐</label>
      <%= f.check_box :recommend %>
    </p>

    <p>
      <label for="product_sex">适合性别</label>
      <%=select(:product ,:sex,[["男",1],["女",0]],{:prompt =>"请选择"}) %>
    </p>

    <p>
      <label for="product_description">描述</label>
    <div id="<%= fckeditor_div_id('product', 'description') %>">
      <%= fckeditor_textarea( "product", "description" ,:toolbarSet => 'Simple', :width => '500', :height => '400') %>
    </div>
  </p>

  <p>
    <%= f.submit button_name,:class=>'submit' %>
  </p>
<% end %>
</div>